import 'package:power_house/pages/home/tab_search/filter_bar/data.dart';
import 'package:scoped_model/scoped_model.dart';

class FilterBarModel extends Model {
  List<GeneralType> _roomTypeList = [];
  List<GeneralType> _orientedList = [];
  List<GeneralType> _floorList = [];

  Set<String> _selectedList = <String>{};

  Map<String, List<GeneralType>> get dataList {
    var result = <String, List<GeneralType>>{};
    result['roomTypeList'] = _roomTypeList;
    result['orientedList'] = _orientedList;
    result['floorList'] = _floorList;
    return result;
  }

  set dataList(Map<String, List<GeneralType>> dataList) {
    if (dataList['roomTypeList'] != null) {
      _roomTypeList = dataList['roomTypeList']!;
    }
    if (dataList['orientedList'] != null) {
      _orientedList = dataList['orientedList']!;
    }
    if (dataList['floorList'] != null) {
      _floorList = dataList['floorList']!;
    }
    //写操作要调用该方法
    notifyListeners();
  }

  Set<String> get selectedList {
    return _selectedList;
  }

  //选中或者移除类型数据
  void selectedListChanged(String data) {
    if (_selectedList.contains(data)) {
      _selectedList.remove(data);
    } else {
      _selectedList.add(data);
    }
    notifyListeners();
  }
}
